/* USER CODE BEGIN Header */
/**
 ******************************************************************************
 * @file           : mf_spi.h
 * @brief          : Header for mf_spi.c file.
 *                   This file contains the common defines of the application.
 ******************************************************************************
 * @attention
 *
 * Copyright (c) [2021] [Fudan Microelectronics]
 * THIS SOFTWARE is licensed under Mulan PSL v2.
 * can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 *
 ******************************************************************************
 */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MF_SPI_H
#define __MF_SPI_H

#ifdef __cplusplus
extern "C"
{
#endif

    /* Includes ------------------------------------------------------------------*/

#include "fm33le0xx_fl.h"

    /* Private includes ----------------------------------------------------------*/
    /* USER CODE BEGIN Includes */

    /* USER CODE END Includes */

    /* Exported types ------------------------------------------------------------*/
    /* USER CODE BEGIN ET */

#define MF_SPI1_BASE (SPI1)
#define MF_SPI1_DMA_ONLY_USE_TX (1)
#define MF_SPI1_DMA_BASE (DMA)
#define MF_SPI1_DMA_TX_CHANNEL (FL_DMA_CHANNEL_6)
#define MF_SPI1_DMA_RX_CHANNEL (FL_DMA_CHANNEL_5)
#define MF_SPI1_DMA_PERIPH_ADDRESS (FL_DMA_PERIPHERAL_FUNCTION1)

    /* USER CODE END ET */

    /* Exported constants --------------------------------------------------------*/
    /* USER CODE BEGIN EC */

    /* USER CODE END EC */

    /* Exported macro ------------------------------------------------------------*/
    /* USER CODE BEGIN EM */

    /* USER CODE END EM */

    /* Exported functions prototypes ---------------------------------------------*/
    /* USER CODE BEGIN EFP */

    void mf_spi_init(void);
    FL_ErrorStatus mf_spi_dma_init(void);
    void mf_spi_write(uint8_t *data, uint16_t length);
#if MF_SPI1_DMA_ONLY_USE_TX
    void spi1_dma_trans(uint8_t *w_buff, uint16_t length);
#else
void spi1_dma_trans(uint8_t *w_buff, uint8_t *r_buff, uint16_t length);
void mf_spi_dma_complete_flag(FL_ITStatus status);
#endif

    /* USER CODE END EFP */

    /* Private defines -----------------------------------------------------------*/

    /* USER CODE BEGIN Private defines */

    /* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MF_SPI_H */

/************************ (C) COPYRIGHT FMSH *****END OF FILE****/
